import {
	ajax,
	isLoginFn,
	getUserInfo
} from '@/common/common.js'
//清除缓存数据
export function clearStorage() {
	uni.getStorageInfo({
		success: function(res) {
			console.log(res.keys);
			console.log(res.currentSize);
			console.log(res.limitSize);
		}
	});
	uni.removeStorageSync('storage_key');
}
//登录成功验证token
export function istoken() {
	let token = uni.getStorageSync('token')
	let info = getUserInfo();
	ajax({
		url: '/deToken',
		method: 'POST',
		data: {
			pid: info.uuid
		},
		accessToken: token.token,
		contentType: 'application/x-www-form-urlencoded',
		success: res => {
			console.log('111111111', res)
			if (res.uid == info.username) {
				console.log("1")
				uni.setStorageSync('userid', {
					userid: res.data.uid
				});
			}
		},
		fail: res => {}
	})
}
//保存用户数据
export function saveUser() {
	console.log("@2")
	let userinfo = uni.getStorageSync('login_info')
	let type = uni.getStorageSync('type')
	let typeone = uni.getStorageSync('fingerStatus')
	let pwd = uni.getStorageSync('gesture')
	let unlockzw= uni.getStorageSync('unlockzw')
	let unlocksh= uni.getStorageSync('unlocksh')
	let authfing=uni.getStorageSync("authfing")
	console.log(userinfo)
	uni.setStorageSync(userinfo.userid, {
		logininfo: userinfo,
		type: type,
		typeone: typeone,
		pwd: pwd,
		unlockzw:unlockzw,
		unlocksh:unlocksh,
		authfing:authfing
	})
	let res = uni.getStorageSync(userinfo.userid)
	console.log(res)
}
